package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.FndCountry;
import com.bestow.basic.service.IFndCountryService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 国家地区定义Controller
 * 
 * @author liliu
 * @date 2022-09-07
 */
@RestController
@RequestMapping("/basic/fndCountry")
public class FndCountryController extends BaseController
{
    @Autowired
    private IFndCountryService fndCountryService;

    /**
     * 查询国家地区定义列表
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCountry:list')")
    @GetMapping("/list")
    public TableDataInfo list(FndCountry fndCountry)
    {
        startPage();
        List<FndCountry> list = fndCountryService.selectFndCountryList(fndCountry);
        return getDataTable(list);
    }

    /**
     * 导出国家地区定义列表
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCountry:export')")
    @Log(title = "国家地区定义", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FndCountry fndCountry)
    {
        List<FndCountry> list = fndCountryService.selectFndCountryList(fndCountry);
        ExcelUtil<FndCountry> util = new ExcelUtil<FndCountry>(FndCountry.class);
        util.exportExcel(response, list, "国家地区定义数据");
    }

    /**
     * 获取国家地区定义详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCountry:query')")
    @GetMapping(value = "/{country}")
    public AjaxResult getInfo(@PathVariable("country") String country)
    {
        return AjaxResult.success(fndCountryService.selectFndCountryByCountry(country));
    }

    /**
     * 新增国家地区定义
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCountry:add')")
    @Log(title = "国家地区定义", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FndCountry fndCountry)
    {
        return toAjax(fndCountryService.insertFndCountry(fndCountry));
    }

    /**
     * 修改国家地区定义
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCountry:edit')")
    @Log(title = "国家地区定义", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FndCountry fndCountry)
    {
        return toAjax(fndCountryService.updateFndCountry(fndCountry));
    }

    /**
     * 删除国家地区定义
     */
    @PreAuthorize("@ss.hasPermi('basic:fndCountry:remove')")
    @Log(title = "国家地区定义", businessType = BusinessType.DELETE)
	@DeleteMapping("/{countrys}")
    public AjaxResult remove(@PathVariable String[] countrys)
    {
        return toAjax(fndCountryService.deleteFndCountryByCountrys(countrys));
    }
}
